<template>
  <div class="dialog">
    <el-dialog
      :title="title"
      :visible.sync="visible"
      :close-on-click-modal="false"
      width="55%"
      top="20vh"
      @close="closeDialog"
    >
      <el-form
        :model="createForm"
        label-width="100px"
        label-suffix=":"
        class="searchw"
        :rules="rule"
        ref="createForm"
      >
        <el-row :gutter="24">
          <el-col :span="12">
            <el-form-item label="退出时间" prop="leaveDate">
              <el-date-picker
                v-model.trim="createForm.leaveDate"
                placeholder="选择日期"
                type="date"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
                :disabled="title == '申请详情'"
                >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="24">
          <el-col :span="24">
            <el-form-item label="退出原因" prop="leaveReason">
              <el-input
                type="textarea"
                v-model.trim="createForm.leaveReason	"
                placeholder="请输入退出原因"
                :disabled="title == '申请详情'"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <div class="page-panel-title" style="margin-top: 0" v-if="title == '申请详情' && row.state!='0'">审核日志</div>
        <examine-log-table v-if="title == '申请详情' && row.state!='0'" :rowData="row" :stateList="stateList"></examine-log-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="closeDialog()">关 闭</el-button>
        <el-button
          type="primary"
          @click="confirmData('createForm')"
          v-if="title != '申请详情'"
          >保 存</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
<script>
import examineLogTable from '../components/examineLogTable.vue'
export default {
  components: { examineLogTable },
  name: 'addBrand',
  props: {
    row: {
      type: Object,
      default: {}
    },
    title: {
      type: String,
      default: ''
    },
    value: {
      type: Boolean,
      default: false
    },
    stateList: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      visible: true,
      createForm: {
        id: '',
        handoverContent: '',
        contentType: '',
      },
      contentTypeList: [
        {
          code: '0',
          name: '普通员工',
        },
        {
          code: '1',
          name: '技工',
        },
        {
          code: '2',
          name: '通用',
        },
      ],
      rule:{
        leaveDate: [
          { required: true, message: '请选择退出时间', trigger: 'change' },
        ],
        leaveReason: [
          { required: true, message: '请输入退出原因', trigger: 'blur' },
        ],
      }
    }
  },
  created() {
    if(this.row.id){
      this.createForm = this.row
    }
  },
  mounted() {},
  methods: {
    confirmData(formName) {
      this.$refs[formName].validate((valid) => {
        if(valid) {
          this.$emit('ok', this.createForm)
        }
      })
    },
    closeDialog() {
      this.$emit('cancle')
    }
  }
}
</script>
<style scoped lang="less">
.el-select,.el-date-editor {
  width: 100%!important;
  /deep/.el-input{
    width: 100%!important;
  }
}
/* 小标题 */
.title {
  display: flex;
  align-items: center;
  margin: 10px 0 15px 0px;
  .label {
    font-weight: bold;
    color: #606266;
    margin-right: 5px;
  }
  .line {
    flex: 1;
    height: 1px;
    background: #dee3ed;
  }
}
</style>
